package com.tree.jvm.gc.mem;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName com.tree.jvm.gc.mem
 * Description: <类功能描述>. <br>
 * <p>
 * 错误原因: java.lang.OutOfMemoryError: Java heap space 堆内存溢出
 * 解决办法:设置堆内存大小 // -Xms1m -Xmx10m -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError
 * </p>
 * @Author tree
 * @Date 2019-11-16 12:57
 * @Version 1.0
 */
public class OutOfMemTest1 {

    public static void main(String[] args) {
        // -Xms1m -Xmx10m -XX:+PrintGCDetails -XX:+HeapDumpOnOutOfMemoryError
        List<Object> listObject = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            System.out.println("i:" + i);
            Byte[] bytes = new Byte[1 * 1024 * 1024];
            listObject.add(bytes);
        }
        System.out.println("添加成功...");

    }
}
